package com.yanfan.ba.service.impl;

import java.util.Arrays;
import java.util.List;

import com.yanfan.ba.domain.NjBaDevice;
import com.yanfan.common.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yanfan.ba.mapper.NjBaDeviceDataMapper;
import com.yanfan.ba.domain.NjBaDeviceData;
import com.yanfan.ba.service.INjBaDeviceDataService;

/**
 * 楼控设备数据Service业务层处理
 *
 * @author genluo
 * @date 2024-11-06
 */
@Service
public class NjBaDeviceDataServiceImpl extends ServiceImpl<NjBaDeviceDataMapper, NjBaDeviceData> implements INjBaDeviceDataService {
    @Autowired
    private NjBaDeviceDataMapper njBaDeviceDataMapper;


    /**
     * 查询楼控设备数据列表
     *
     * @param njBaDeviceData 楼控设备数据
     * @return 楼控设备数据
     */
    @Override
    public List<NjBaDeviceData> queryPageList(NjBaDeviceData njBaDeviceData) {
        LambdaQueryWrapper<NjBaDeviceData> lqw = buildQueryWrapper(njBaDeviceData);
        return njBaDeviceDataMapper.selectList(lqw);
        //连表查询可用该方法，在此方法SQL语句上进行扩展
        //return njBaDeviceDataMapper.queryPageList(njBaDeviceData);
    }

    /**
    * 分页查询条件
    * @return
    */
    private LambdaQueryWrapper<NjBaDeviceData> buildQueryWrapper(NjBaDeviceData bo) {
        LambdaQueryWrapper<NjBaDeviceData> lqw = Wrappers.lambdaQuery();
        lqw.like(StringUtils.isNotBlank(bo.getTagNumber()), NjBaDeviceData::getTagNumber, bo.getTagNumber());
        lqw.like(StringUtils.isNotBlank(bo.getDescription()), NjBaDeviceData::getDescription, bo.getDescription());
        lqw.like(StringUtils.isNotBlank(bo.getDeviceName()), NjBaDeviceData::getDeviceName, bo.getDeviceName());
        lqw.orderByDesc(NjBaDeviceData :: getUpdateTime);
        return lqw;
    }



}
